package thread;

/**
 * @author zhangjie
 */
public class SynchronizedTest {


  public synchronized void method(){
    System.out.println("开始");
    try {
      Thread.sleep(2000);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
    System.out.println("结束");
  }

  public static void main(String[] args) {
    SynchronizedTest synchronizedTest = new SynchronizedTest();
    new Thread(() -> synchronizedTest.method()).start();
    new Thread(() -> synchronizedTest.method()).start();
  }
}
